
#! /usr/bin/python

from networking.datatrans import BlockNegoTrans
from networking.serverhandler import WelcomeRH
from networking.requesthandler import RequestHandlerThread
from networking.serverhandler import BasicServerMap
#from SocketServer import ThreadingTCPServer
from socket import *
from transfile import *
from threading import Thread

__author__="ken"
__date__ ="$2009-2-4 15:26:37$"


class ConnectionHandle(Thread):
    pass

def runServer():
    ss = socket(AF_INET, SOCK_STREAM)
    ss.setsockopt(SOL_SOCKET, SO_REUSEADDR, 1 )
    # self ip, 127.0.0.1 not useable
    ss.bind(("127.0.0.1", 2010))
    ss.listen(1)
    client, addr = ss.accept()
    
    # start
    '''
    dest = open("e:\\temp\\wxPython2.8-win32-docs-demos-2.8.9.1.exe", "wb")
    recvFile(dest, client)
    client.close()
    dest.close()
    ss.close()
    '''
    #print client
    bsm = BasicServerMap()
    rst = RequestHandlerThread((client, addr), None, WelcomeRH, bsm, BlockNegoTrans)
    rst.start()
    rst.join()
    #print "joined"



if __name__ == "__main__":
    runServer()

